package stardust.product.j2d.support;

import java.awt.BorderLayout;

import javax.swing.JFrame;

import stardust.product.j2d.GraphicsContainer;

public class GraphicsWindow extends JFrame
{
	
	private GraphicsContainer graphicsContainer;
	
	public GraphicsWindow(int width, int height)
	{
		this.setIgnoreRepaint(true);
//		this.setUndecorated(true);
		this.setSize(width, height);
		this.setLayout(new BorderLayout());
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
		
		this.graphicsContainer = GraphicsContainer.getSimpleGraphicsContainer(width, height);
		this.add(this.graphicsContainer);
		this.graphicsContainer.initialize();
		
		final GraphicsWindow _this = this;
		new Thread()
		{
			public void run()
			{
				try
				{
					while (!Thread.interrupted())
					{
						_this.graphicsContainer.refresh();
						Thread.sleep(50);
					}
				}
				catch (InterruptedException e)
				{
					return;
				}
			}
		}.start();
	}
	
	public static void main(String[] args)
	{
		new GraphicsWindow(500, 400);
	}

}
